
<!-- 引入基类模板 -->
{extend name='public/base' /}


{block name="search"}

{:widget('forms/search',array('name','部门名称','请输入部门名称'))}

{/block}

{block name="btn"}
<!--按钮区-->

{:widget('forms/reload')}

<!--<a class="layui-btn layui-btn-sm layui-btn-normal" href='http://192.168.8.110:8098/bioLogin.do' target="_blank">设置门禁权限</a>-->

{/block}

{block name="table"} <!--表格区-->

{:widget('forms/table')}

{/block}

{block name="js"} <!--js处理区-->

<!--模板-->
<script type="text/html" id="operationTpl">

    {:widget('forms/Operationbtn',array('设置电梯楼层','orderprinter'))}

</script>

<style type="text/css">
    .layui-table-cell{
        text-align:center;
        height: auto;
        white-space: normal;
    }
    .layui-table img{
        max-width:300px;
        max-height: 50px;
    }
</style>


<script>

    layui.use(['element', 'table', 'form', 'jquery', 'laydate','lucky'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var laydate = layui.laydate;

        var lucky=layui.lucky;

        form.render();


        // layer.load(2);
        table.render({
            elem: '#tableFilter',
            url:"{:url('department/index')}",
            //toolbar: '#toolbarDemo',
            even: true, //开启隔行背景
            id:'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                ,groups: 5 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limit:20
                ,limits:[20,30,40,50,60,100]
            },
            // height: 'full-100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                // {type: 'checkbox'},
                {field: 'department_id',  title: '部门ID', align: 'center',width:110},
                {field: 'title', minWidth: 80, align: 'center', title: '部门名称'},
                {field: 'floorinfo', minWidth: 200, align: 'center', title: '授权楼层'},
                {fixed: 'right',templet: '#operationTpl', width: 180, align: 'center', title: '操作'}
            ]],

            done: function (res) {
                layer.closeAll('loading');
            }
        });


        /**
         * 表格搜索
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch("table_id",obj.field); //查询
            return false;
        });


        /**
         * 监听单行工具操作
         */
        table.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            // console.log(JSON.stringify(data));
            var _id=parseInt(data.department_id);
            var layEvent = obj.event;
            // console.log(layEvent);return false;
            if(layEvent==="orderprinter"){
                var urls="/admin/department/setfloor/id/"+_id;
                lucky.CreateForm("设置"+data.title+"的电梯楼层",'55%','50%',urls,"table_id");
            }
        });


        var active = {
            reload: function(){
                lucky.CreateReload("table_id");
            }

        };

        $('.do_btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });



    });

</script >



{/block}
